package com.ca.singlesignon.config;

import lombok.extern.slf4j.Slf4j;
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
@Slf4j
public class RedissonManager {

    private Config config=new Config();

    private Redisson redisson=null;

    public Redisson getRedisson() {
        return redisson;
    }

    private static  String ip="45.40.207.174";
    private static  String password="gary";
    private static  Integer port=6379;

    @PostConstruct
    private void init(){
        try {
            String address=new StringBuilder().append(ip).append(":").append(port).toString();
            config.useSingleServer().setAddress(address).setPassword(password);
            redisson=(Redisson) Redisson.create(config);
            log.info("初始化Redisson");
        } catch (Exception e) {
          log.error("redisson init error:{}",e);
        }
    }
}
